package com.lggry.demo6collection;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;

public class CollectionDemo2 {
    public static void main(String[] args) {
        //目标：Collection提供的集合的整体特点
        Collection<String> list = new ArrayList<>();

        //添加元素
        list.add("Java");
        list.add("C++");
        list.add("Python");
        System.out.println(list);

        System.out.println(list.size());
        System.out.println(list.isEmpty());
        //清空集合
        //list.clear();

        //把集合转换成数组
        Object[] arr = list.toArray();
        System.out.println(Arrays.toString(arr));

        //把集合转换成字符串数组（拓展）
        String[] arr2 = list.toArray(String[]::new);

    }
}
